package com.cleverest.cleverestdiary.mapper;

import com.cleverest.cleverestdiary.pojo.ScheduleCategory;
import org.apache.ibatis.annotations.*;

import java.util.List;

@Mapper
public interface ScheduleCategoryMapper {

    @Select("select * from schedule_category where category_name=#{categoryName}")
    ScheduleCategory findByScheduleCategoryName(String name);
    /**
     * 新增
     *
     * @param scheduleCategory
     */
    @Insert("insert into schedule_category(category_name,category_alias,create_user,create_time,update_time)" +
            "values(#{categoryName},#{categoryAlias},#{createUser},#{createTime},#{updateTime})")
    void add(ScheduleCategory scheduleCategory);

    /**
     * 查询所有
     *
     * @param userId
     * @return
     */
    @Select("select * from schedule_category where create_user =#{userId}")
    List<ScheduleCategory> list(Integer userId);

    /**
     * 根据id查询
     *
     * @param id
     * @return
     */
    @Select("select * from schedule_category where id = #{id}")
    ScheduleCategory findById(Integer id);

    /**
     * 更新
     *
     * @param scheduleCategory
     */
    @Update("update schedule_category set category_name=#{categoryName},category_alias=#{categoryAlias},update_time=#{updateTime} where id=#{id}")
    void update(ScheduleCategory scheduleCategory);

    /**
     * 删除文章分类
     *
     * @param id
     */
    @Delete("DELETE FROM schedule_category WHERE id = #{id}")
    void delete(Integer id);
}